<?php
/**
 * 
 * 
 * @author Hồ Hữu Tài <ho.huutai@gnt.com.vn>
 * @Url
 * @Update History
 *      Date(yyyy/mm/dd)  |      Editor          |      Description
 *   2011/11/29                 Hồ Hữu Tài              create new
 */
class Logger
{
    const TRACE_LEVEL = "trace";
    const INFO_LEVEL = "info";
    const ERROR_LEVEL = "error";
    const WARNING_LEVEL = "warning";

    /**
     *
     * @param string $message Log message
     * @param string $level 4 levels: TRACE_LEVEL, INFO_LEVEL, ERROR_LEVEL, WARNING_LEVEL
     * @param string $category message category
     */
    public static function writeLog($message, $level, $category)
    {
        //Yii::log($message, $level, $category);
        //error_log(" [$level] [$category] $message\n");
        $log = new Log();
        $log->category = $category;
        $log->level = $level;
        $log->message = $message;
        $log->log_date = date('Y-m-d H:i:s');
        $log->log_by = Yii::app()->user->name;
        
        $log->save();
    }

}

?>